package com.yicheng.controller;

import com.yicheng.controller.utils.R;
import com.yicheng.entity.Rotation;
import com.yicheng.service.RotationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/rotation")
public class RotationController {

    @Autowired
    private RotationService rotationService;

    @GetMapping("/getRotation")
    public R getRotation(){
        R r = new R();
        try{
            List<Rotation> rotations = rotationService.list();
            r.setList(rotations);
        }catch (Exception e){
            r.setStatus(false);
            r.setMsg(e.getMessage());
        }
        return r;
    }

}
